@extends('layouts.layouts')

<style>
    .layui-form-radio {
        margin: 0px;
    }

    .layui-form-select dl {
        z-index: 9990;
    }

    .lay-ext-mulitsel .layui-input.multiple a {
        height: auto;
    }

    .form-group {
        overflow: hidden;
    }
</style>
@section('title')
    添加配置
@endsection
@section('content')
    <div class="" style="width: 100%;background: #fff;">
        <div class="">
            <div class="ibox ">
                <form>
                <div class="ibox-content">
                    <form>
                        <input type="hidden" id="escort_id" value="{{$escort_id}}">
                        <input type="hidden" name="is_leader" value="1">
                        <input type="hidden" name="callback" value="setLeader">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: auto;">用户昵称、手机号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="query[keywords]" value="{{$query['keywords']}}" placeholder="请输入" id="keywords" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" style="padding-bottom: 5px">
                            <div class="layui-input-inline">
                                <button class="btn btn-success" type="submit">搜索</button>
                            </div>
                        </div>
                    </form>
                    <table class="layui-table">
                        <tbody>
                        @foreach($pager as $item)
                            <tr class="line">
                                <td><input type="checkbox" class="check_item check_item_{{$item->id}}" data-id="{{$item->id}}"></td>
                                <td>{{$item->id}}</td>
                                <td>
                                    昵称：{{$item->nickname}}<br>
                                    手机号：{{$item->mobile}}
                                </td>
                                <td>
                                    <a href="{{($item->avatar)}}" target="_blank">
                                        <img src="{{($item->avatar)}}" class="rounded-circle img-md"/>
                                    </a>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    <div style="text-align: center">
                        <input style="width: 200px" type="button" class="btn btn-success commit" value="确定">
                    </div>
                    @include('common.pagination', ['pager' => $pager])
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script>
        $(".commit").click(function () {
            layer.closeAll();
            var index = parent.layer.getFrameIndex(window.name);
            if (index) {
                parent.layer.close(index);
            }
            //获取选择的用户id
            var value =  $(".check_item:checked").first().data('id');
            var escort_id = $('#escort_id').val()
            //调用父类方法
            window.parent.{{$callback}}(value,escort_id);
        });
    </script>
@endsection